<%@ page import="com.demo.servlet.demo1213.entity.Person" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %><%--
  Created by IntelliJ IDEA.
  User: WuLiangHang
  Date: 2021/12/13
  Time: 9:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--代码脚本--%>
<%
    //代码脚本
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" http-equiv="refresh" content="1">
    <title>计时HTML</title>
</head>
<body>
<%--输出脚本--%>
<%
    //输出脚本
%>
<h1><%=sdf.format(new Date())%>
</h1>
<%
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= i; j++) {
%>
<%=j + " * " + i + " = " + (i * j) + "\t"%>
<%
    }
%>
<br/>
<%
    }
%>

<%--1.声明类属性--%>
<%!
    private static Integer age;
    private String name;
    private static Map<String, Object> map;
%>
<%--2.声明 static 静态代码块--%>
<%!
    static {
        age = 1;
        map = new HashMap<>();
        map.put("key1", "value1");
        map.put("key2", "value2");
        map.put("key3", "value3");
        map.put("key4", "value4");
        map.put("key5", "value5");
    }
%>
<%--3.定义方法--%>
<%!
    public int sum(int a, int b) {
        return a + b;
    }
%>
<%--前面定义的方法 可以直接在后面进行调用--%>
<%=sum(3, 4)%>
<%--4.定义内部类--%>
<%!
    public class AClass {
        private Integer id = 1;
        private String name = "张三";
    }
%>
<%--1.输出对象--%>
<%=new Person(1, "张三", 18, "男")%>
<%--2.输出字符串--%>
<%="123456ABC"%>
<%--3.输出数字--%>
<%=123%>
<%=123.4%>
<%--4.输出日期--%>
<%=new Date()%>

<%--代码脚本--%>
<%--1.if语句--%>
<%
    int age = 17;
    if (age >= 18) {
%>
<h1>《在线发牌》</h1>
<%
} else {
%>
<h1>《小猪佩奇》</h1>
<%
    }
%>
<%--2.for循环--%>
<%
    for (int i = 0; i < 10; i++) {
%>
<h1><%=i%>
</h1>
<%
    }
%>
<%--3.while循环--%>
<%
    int i = 20;
    while (true) {
        if (i++ > 30) {
            break;
        }
%>
<h1><%=i%></h1>
<%
    }
%>
</body>
</html>
